package ch.zbw.pra.sysventory.domain.visualisation;

import java.util.ArrayList;
import java.util.List;

import ch.zbw.pra.sysventory.domain.model.OperatingSystem;

public class VisuControllOS extends AVisuControll implements IVisuControll<OperatingSystem> {

	private boolean osName;
	private boolean buildNr;
	private boolean architektur;

	public VisuControllOS() {
		super();
	}

	public boolean isOsName() {
		return this.osName;
	}

	public void setOsName(boolean osName) {
		this.osName = osName;
		updateObserver();
	}

	public boolean isBuildNr() {
		return this.buildNr;
	}

	public void setBuildNr(boolean buildNr) {
		this.buildNr = buildNr;
		updateObserver();
	}

	public boolean isArchitektur() {
		return this.architektur;
	}

	public void setArchitektur(boolean architektur) {
		this.architektur = architektur;
		updateObserver();
	}

	public void addDataToRow(List<OperatingSystem> data, List<List<String>> row) {
		for (int i = 0; i < data.size(); i++) {
			OperatingSystem os = data.get(i);
			if (isOsName()) {
				row.add(makeOperatingSystemNameList(os));
			}
			if (isBuildNr()) {
				row.add(makeOperatingSystemBuildList(os));
			}
			if (isArchitektur()) {
				row.add(makeOperatingSystemArchitectureList(os));
			}
		}
	}

	public void addDataToColumn(List<String> data) {
		if (isOsName()) {
			data.add("Betriebssystem Name");
		}
		if (isBuildNr()) {
			data.add("Buildnummer");
		}
		if (isArchitektur()) {
			data.add("Architektur");
		}

	}

	private List<String> makeOperatingSystemNameList(OperatingSystem os) {
		List<String> data = new ArrayList<String>();
		data.add(os.getNameOperatingSystem());
		return data;
	}

	private List<String> makeOperatingSystemBuildList(OperatingSystem os) {
		List<String> data = new ArrayList<String>();
		data.add(os.getBuildOperatingSystem());
		return data;
	}

	private List<String> makeOperatingSystemArchitectureList(OperatingSystem os) {
		List<String> data = new ArrayList<String>();
		data.add(os.getArchitecture32Bit64BitOperatingSystem());
		return data;
	}

	public void restoreTo(boolean value) {
		this.osName = value;
		this.buildNr = value;
		this.architektur = value;
	}
}
